﻿@{
    Layout = "../Shared/_AngularJSLayout.cshtml";
}

@Html.Partial("Head")

@section foot
{
    <script>
        
    </script>
}


 
<div ng-controller="Controller">
    <form novalidate class="css-form">
        Name:
        <input type="text" ng-model="user.name" required /><br />
     
        E-mail: <input type="email" ng-model="user.email" required /><br />
        Gender: <input type="radio" ng-model="user.gender" value="male" />male
        <input type="radio" ng-model="user.gender" value="female" />female<br />
        <input type="text"  name="test"  /><br />
        <button ng-click="reset()">RESET</button>
        <button ng-click="update(user)">SAVE</button>
    </form>
    
    <ul ng-repeat="pro in getList()">
        <li ng-click="refresh()">  {{pro.name}} <input type="checkbox" name="{{pro.name}}" value="{{pro.type}}" />  </li>
    </ul>

    <pre>form = {{user | json}}</pre>
    <pre>master = {{master | json}}</pre>
</div>

<style type="text/css">
    .css-form input.ng-invalid.ng-dirty {
        background-color: #FA787E;
    }

    .css-form input.ng-valid.ng-dirty {
        background-color: #78FA89;
    }
</style>

<script type="text/javascript">
    function Controller($scope) {
        $scope.master = {};
        $scope.list = [];
        $scope.list.push({
            name: "gaoxian",
            type:1
        });
        $scope.list.push({
            name: "luowen",
            type:2
        });
        $scope.getList = function() {
            return $scope.list;
        };

        $scope.update = function (user) {
            $scope.master = angular.copy(user);
        };

        $scope.reset = function () {
            $scope.user = angular.copy($scope.master);
        };
        $scope.refresh = function () {
            console.log("ccccc");
        };

        $scope.reset();
    }
</script>
